import 'package:aio/aio.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:app/generated/app_strings.dart';
import 'package:app/src/http/bean/http_data.dart';
import 'package:app/src/http/bean/wroks/address_bean.dart';
import 'package:app/src/http/bean/wroks/contract_bean.dart';
import 'package:app/src/ui/route/helper/route_helper.dart';
import 'package:app/src/ui/route/works/public/items/ui_base.dart';
import 'package:app/src/ui/route/works/public/items/ui_card.dart';

import '../../../../../../http/bean/worksdo/equipment_management_bean.dart';
import '../../../../../../http/bean/worksdo/material_requisition_bean.dart';
import '../../../../../../http/bean/wroks/dispatchingaudit_bean.dart';
import '../../../../../../http/model/config_model.dart';
import '../../../../../app_ui.dart';
import '../../../../../dialog/dailog.dart';

///设备报修：其他工单
class UiOther {
  ///data 信息
  ///oldData 历史信息
  static Widget build(BuildContext context,
      GetMyRepairOrderInfoBean? myRepairOrderInfoBean, StateSetter setState,
      {String? title}) {
    EquipmentInfo? data = myRepairOrderInfoBean?.OrderInfo;
    EquipmentInfo? oldData = null;
    if (data == null) {
      return AppUi.getEmptyView();
    }
    List<Widget> children = [];
    if (StringUtils.isEmpty(title)) {
      title = AppStrings.of(context).Equipmentrepair; //设备报修
    }
    children.add(UiBase.title(context, title)); //标题
    var isAllowEmpty = true;
    var isGrey = false;
    String defaultValue="";
    children.add(UiBase.item(context, AppStrings.of(context).TicketNo,
        data?.RepairNo, oldData?.RepairNo,
        isAllowEmpty: isAllowEmpty,
        defaultValue: defaultValue,
        isGrey: isGrey)); //工单号
    children.add(UiBase.item(
        context,
        AppStrings.of(context).Lv,
        data?.getUrgencyLevelName(context),
        oldData?.getUrgencyLevelName(context),
        isAllowEmpty: isAllowEmpty,
        defaultValue: defaultValue,
        isGrey: isGrey)); //等级
    children.add(UiBase.item(context, AppStrings.of(context).Workordername,
        data?.EquipmentName1, oldData?.EquipmentName1,
        isAllowEmpty: isAllowEmpty,
        defaultValue: defaultValue,
        isGrey: isGrey)); //工单名称（使用一级设备名称的字段）
    children.add(UiBase.item(context, AppStrings.of(context).Workordertype,
        data?.getRepairTypeName(context), oldData?.getRepairTypeName(context),
        isAllowEmpty: isAllowEmpty,
        defaultValue: defaultValue,
        isGrey: isGrey)); //工单类型
    children.add(UiBase.item(context, AppStrings.of(context).collaborator,
        myRepairOrderInfoBean?.getCollaboratorName(), null,
        isAllowEmpty: isAllowEmpty,
        defaultValue: defaultValue,
        isGrey: isGrey)); //协同人员
    children.add(UiBase.item(
        context,
        AppStrings.of(context).Estimatedworkinghours2_,
        "${myRepairOrderInfoBean?.getWorkHours()}\t${AppStrings.of(context).hours}",
        null,
        isAllowEmpty: isAllowEmpty,
        defaultValue: defaultValue,
        isGrey: isGrey)); //预计工时

    var column = UiBase.column(context, children);
    var card = UiCard.build(context, column);
    return card;
  }
}
